package com.gf.forcesystem.config;

import com.gf.framework.common.utils.list.GfLinkedList;
import com.gf.framework.rabbitmq.model.BindingInfo;
import com.gf.framework.rabbitmq.model.ExchangeInfo;
import com.gf.framework.rabbitmq.model.ExchangeType;
import com.gf.framework.rabbitmq.model.QueueInfo;
import com.gf.framework.rabbitmq.porperties.MqProperties;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author gaofei
 * @date 2022/6/19 15:24
 * 无人机信息配置
 */
@Component
public class CotaskingRabbitmqConfig implements MqProperties {
    public static final String targetExchangeName = "Cotasking.TargetExchange";
    /**
     * 无人机状态交换机
     */
    public static final String uavSystemExchangeName = "Cotasking.UAVSystemExchange";

    /**
     * 无人机天气交换机
     */
    public static final String weatherExchangeName = "Cotasking.WeatherExchange";

    /**
     * 无人机天气交换key
     */
    public static final String weatherRoutingKey = "Cotasking.Weather";

    public static final String targetStateRoutingKey = "Cotasking.TargetState";

    /**
     * 模型状态帧队列
     */
    public static final String targetStateQueue = "Cotasking.TargetState.VirtualForceQueue";

    /**
     * 目标击毁帧队列
     */
    public static final String targetDestroyQueue = "Cotasking.TargetDestroy.VirtualForceQueue2";

    /**
     * 无人机状态帧队列
     */
    public static final String uavStateQueue = "Cotasking.UAVSystem.VirtualForceQueue2";

    public static final String weatherQueue = "Cotasking.Weather. VirtualForceQueue2";

    /**
     * 交换机信息
     * @return
     */
    @Override
    public List<ExchangeInfo> getExchanges() {
        ExchangeInfo targetStateExchange = new ExchangeInfo(targetExchangeName, ExchangeType.TOPIC);
        targetStateExchange.setAutoDelete(false);
        targetStateExchange.setDurable(true);

        ExchangeInfo uavExchange = new ExchangeInfo(uavSystemExchangeName, ExchangeType.TOPIC);
        uavExchange.setAutoDelete(false);
        uavExchange.setDurable(true);


        ExchangeInfo weatherExchange = new ExchangeInfo(weatherExchangeName, ExchangeType.TOPIC);
        uavExchange.setAutoDelete(false);
        uavExchange.setDurable(true);

        return new GfLinkedList<ExchangeInfo>().of(targetStateExchange, uavExchange, weatherExchange);
    }

    /**
     * 队列信息
     * @return
     */
    @Override
    public List<QueueInfo> getQueues() {
        QueueInfo targetStateQueue = QueueInfo.builder().name(CotaskingRabbitmqConfig.targetStateQueue).
                autoDelete(false).durable(true).messageTtl(1000L).build();
        targetStateQueue.binding(new BindingInfo(targetExchangeName,"Cotasking.TargetState"));

        QueueInfo targetDestroyQueue = QueueInfo.builder().name(CotaskingRabbitmqConfig.targetDestroyQueue).
                autoDelete(false).durable(true).messageTtl(1000L).build();
        targetDestroyQueue.binding(new BindingInfo(targetExchangeName,"Cotasking.TargetDestroy.*"));

        QueueInfo uavStateQueue = QueueInfo.builder().name(CotaskingRabbitmqConfig.uavStateQueue).
                autoDelete(false).durable(true).messageTtl(1000L).build();
        uavStateQueue.binding(new BindingInfo(uavSystemExchangeName,"Cotasking.UAVSystemState.*"));

        QueueInfo weatherQueue =  QueueInfo.builder().name(CotaskingRabbitmqConfig.weatherQueue).
                autoDelete(false).durable(true).messageTtl(1000L).build();
        weatherQueue.binding(new BindingInfo(weatherExchangeName, weatherRoutingKey));

        return new GfLinkedList<QueueInfo>().of(targetStateQueue, targetDestroyQueue, uavStateQueue, weatherQueue);
    }
}
